<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="pagePath" value="${pageContext.request.contextPath}" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>人事管理系统——修改员工</title>
<link type="text/css" rel="stylesheet" href="${pagePath}/page/static/css/css.css" />
<link type="text/css" rel="stylesheet" href="${pagePath}/page/static/js/ligerUI/skins/Aqua/css/ligerui-dialog.css" />
<link type="text/css" rel="stylesheet" href="${pagePath}/page/static/js/ligerUI/skins/ligerui-icons.css" />
<link type="text/css" rel="stylesheet" href="${pagePath}/page/static/css/pager.css" />
<script type="text/javascript" src="${pagePath}/page/static/js/jquery-1.11.0.js"></script>
<script type="text/javascript" src="${pagePath}/page/static/js/jquery-migrate-1.2.1.js"></script>
<script type="text/javascript" src="${pagePath}/page/static/js/ligerUI/js/core/base.js"></script>
<script type="text/javascript" src="${pagePath}/page/static/js/ligerUI/js/plugins/ligerDrag.js"></script>
<script type="text/javascript" src="${pagePath}/page/static/js/ligerUI/js/plugins/ligerDialog.js"></script>
<script type="text/javascript" src="${pagePath}/page/static/js/ligerUI/js/plugins/ligerResizable.js"></script>
<script type="text/javascript" src="${pagePath}/page/static/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	$(function() {
		// 控制文档加载完成以后 选中性别 
		/** 员工表单提交 */
		$("#employeeForm").submit(function() {
			var name = $("#name");
			var cardId = $("#cardId");
			var sex = $("#sex");
			var job_id = $("#job_id");
			var education = $("#education");
			var email = $("#email");
			var mobile = $("#mobile");
			var telephone = $("#telephone");
			var party = $("#party");
			var qq = $("#qq");
			var address = $("#address");
			var postCode = $("#postCode");
			var birthday = $("#birthday");
			var race = $("#race");
			var speciality = $("#speciality");
			var hobby = $("#hobby");
			var department_id = $("#department_id");
			var msg = "";
			if ($.trim(name.val()) == "") {
				msg = "姓名不能为空！";
				name.focus();
			} else if ($.trim(cardId.val()) == "") {
				msg = "身份证号码不能为空！";
				cardId.focus();
			} else if (!/^[1-9]\d{16}[0-9A-Za-z]$/.test($.trim(cardId.val()))) {
				msg = "身份证号码格式不正确！";
				cardId.focus();
			} else if ($.trim(sex.val()) == "") {
				msg = "请选择性别！";
				sex.focus();
			} else if ($.trim(job_id.val()) == "") {
				msg = "请选择工作！";
				job_id.focus();
			} else if ($.trim(education.val()) == "") {
				msg = "学历不能为空！";
				education.focus();
			} else if ($.trim(email.val()) == "") {
				msg = "邮箱不能为空！";
				email.focus();
			} else if (!/^\w+@\w{2,3}\.\w{2,6}$/.test($.trim(email.val()))) {
				msg = "邮箱格式不正确！";
				email.focus();
			} else if ($.trim(mobile.val()) == "") {
				msg = "手机号码不能为空！";
				mobile.focus();
			} else if (!/^1[3|5|8]\d{9}$/.test($.trim(mobile.val()))) {
				msg = "手机号码格式不正确！";
				mobile.focus();
			} else if ($.trim(telephone.val()) == "") {
				msg = "电话号码不能为空！";
				telephone.focus();
			} else if (!/^0\d{2,3}-?\d{7,8}$/.test($.trim(telephone.val()))) {
				msg = "电话号码格式不正确！";
				telephone.focus();
			} else if ($.trim(party.val()) == "") {
				msg = "政治面貌不能为空！";
				party.focus();
			} else if ($.trim(qq.val()) == "") {
				msg = "QQ号码不能为空！";
				qq.focus();
			} else if (!/^\d{6,}$/.test($.trim(qq.val()))) {
				msg = "QQ号码格式不正确！";
				qq.focus();
			} else if ($.trim(address.val()) == "") {
				msg = "地址不能为空！";
				address.focus();
			} else if ($.trim(postCode.val()) == "") {
				msg = "邮政编码不能为空！";
				postCode.focus();
			} else if (!/^[1-9]\d{5}$/.test($.trim(postCode.val()))) {
				msg = "邮政编码格式不正确！";
				postCode.focus();
			} else if ($.trim(birthday.val()) == "") {
				msg = "出生日期不能为空！";
				birthday.focus();
			} else if (!birthday.val()) {
				// !/^\d{4}-\d{2}-\d{2}$/.test($.trim(birthday.val()))
				msg = "出生日期格式不正确！";
				birthday.focus();
			} else if ($.trim(race.val()) == "") {
				msg = "民族不能为空！";
				race.focus();
			} else if ($.trim(speciality.val()) == "") {
				msg = "专业不能为空！";
				speciality.focus();
			} else if ($.trim(hobby.val()) == "") {
				msg = "爱好不能为空！";
				hobby.focus();
			} else if ($.trim(department_id.val()) == "") {
				msg = "请选择部门！";
				department_id.focus();
			}
			if (msg != "") {
				$.ligerDialog.error(msg);
				return false;
			} else {
				return true;
			}
			$("#employeeForm").submit();
		});
	});
</script>
</head>
<body>
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td height="10"></td>
		</tr>
		<tr>
			<td width="15" height="32"><img src="${pagePath}/page/static/images/main_locleft.gif" width="15" height="32"></td>
			<td class="main_locbg font2"><img src="${pagePath}/page/static/images/pointer.gif">&nbsp;当前位置：员工管理&nbsp;&gt;&nbsp;修改员工</td>
			<td width="15" height="32"><img src="${pagePath}/page/static/images/main_locright.gif" width="15" height="32"></td>
		</tr>
	</table>
	<table width="100%" height="90%" border="0" cellpadding="5" cellspacing="0" class="main_tabbor">
		<tr valign="top">
			<td>
				<form action="${pagePath}/employee/modify.do" id="employeeForm" method="post">
					<!-- 隐藏表单，flag表示添加标记 -->
					<input type="hidden" name="flag" value="2"> <input type="hidden" name="id" value="${employee.id}">
					<table width="100%" border="0" cellpadding="0" cellspacing="10" class="main_tab">
						<tr>
							<td class="font3 fftd">
								<table>
									<tr>
										<td class="font3 fftd">姓名：<input type="text" name="name" id="name" size="20" value="${employee.name}" /></td>
										<td class="font3 fftd">身份证号码：<input type="text" name="cardId" id="cardId" size="20" value="${employee.cardId}" /></td>
									</tr>
									<tr>
										<td class="font3 fftd">性别： <select id="sex" name="sex" style="width: 143px;">
												<c:if test="${employee.sex == 1}">
													<option value="1" selected="selected">男</option>
													<option value="0">女</option>
												</c:if>
												<c:if test="${employee.sex == 2}">
													<option value="1">男</option>
													<option value="0" selected="selected">女</option>
												</c:if>
										</select>
										</td>
										<td class="font3 fftd">职&nbsp;&nbsp;&nbsp;位： <select id="job_id" name="job_id" style="width: 143px;">
												<option value="">--请选择职位--</option>
												<c:forEach items="${jobs}" var="job">
													<c:choose>
														<c:when test="${employee.jobId == job.id}">
															<option value="${job.id}" selected="selected">${job.name}</option>
														</c:when>
														<c:otherwise>
															<option value="${job.id}">${job.name}</option>
														</c:otherwise>
													</c:choose>
												</c:forEach>
										</select>
										</td>
									</tr>
									<tr>
										<td class="font3 fftd">学历：<input name="education" id="education" size="20" value="${employee.education}" /></td>
										<td class="font3 fftd">邮&nbsp;&nbsp;&nbsp;箱：<input name="email" id="email" size="20" value="${employee.email}" /></td>
									</tr>
									<tr>
										<td class="font3 fftd">手机：<input name="mobile" id="mobile" size="20" value="${employee.mobile}" /></td>
										<td class="font3 fftd">电&nbsp;&nbsp;&nbsp;话：<input name="telephone" id="telephone" size="20" value="${employee.telephone}" /></td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td class="main_tdbor"></td>
						</tr>
						<tr>
							<td class="font3 fftd">政治面貌：<input name="party" id="party" size="40" value="${employee.party}" />&nbsp;&nbsp;QQ&nbsp;号码：<input name="qq" id="qq" size="20" value="${employee.qq}" />
							</td>
						</tr>
						<tr>
							<td class="main_tdbor"></td>
						</tr>
						<tr>
							<td class="font3 fftd">联系地址：<input name="address" id="address" size="40" value="${employee.address}" />&nbsp;&nbsp;邮政编码：<input name="postCode" id="postCode" size="20" value="${employee.postCode}" />
							</td>
						</tr>
						<tr>
							<td class="main_tdbor"></td>
						</tr>
						<tr>
							<td class="font3 fftd">出生日期：<input onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'});" name="birthday" id="birthday" size="40" value='<fmt:formatDate value="${employee.birthday}" pattern="yyyy-MM-dd" />' />&nbsp;&nbsp;民&nbsp;&nbsp;族：<input name="race" id="race" size="20" value="${employee.race}" />
							</td>
						</tr>
						<tr>
							<td class="main_tdbor"></td>
						</tr>
						<tr>
							<td class="font3 fftd">所学专业：<input name="speciality" id="speciality" size="40" value="${employee.speciality}" />&nbsp;&nbsp;爱&nbsp;&nbsp;好：<input name="hobby" id="hobby" size="20" value="${employee.hobby}" />
							</td>
						</tr>
						<tr>
							<td class="main_tdbor"></td>
						</tr>
						<tr>
							<td class="font3 fftd">备&nbsp;&nbsp;注：<input name="remark" id="remark" size="40" value="${employee.remark}" />&nbsp;&nbsp;所属部门： <select id="department_id" name="department_id" style="width: 100px;">
									<option value="">--部门选择--</option>
									<c:forEach items="${departments}" var="department">
										<c:choose>
											<c:when test="${employee.departmentId == department.id}">
												<option value="${department.id}" selected="selected">${department.name}</option>
											</c:when>
											<c:otherwise>
												<option value="${department.id}">${department.name}</option>
											</c:otherwise>
										</c:choose>
									</c:forEach>
							</select>
							</td>
						</tr>
						<tr>
							<td class="main_tdbor"></td>
						</tr>
						<tr>
							<td align="left" class="fftd"><input type="submit" value="修改">&nbsp;&nbsp;<input type="button" onclick="location.href='${pagePath}/employee/list.do'" value="取消 "></td>
						</tr>
					</table>
				</form>
			</td>
		</tr>
	</table>
	<div style="height: 10px;"></div>
</body>
</html>